package com.rfid.protocol;

/**
 * @author Administrator
 * @date 2020/9/16
 * 抽象的指令对象
 */
public abstract class Instruction {

    //   public abstract byte[] getSendData();

    public abstract byte[] getCommand();

    public abstract void invoke(byte[] data);

    public String bytesToHexString(byte[] src) {

        StringBuilder stringBuilder = new StringBuilder();

        if (src == null || src.length <= 0) {

            return null;

        }

        for (int i = 0; i < src.length; i++) {

            int v = src[i] & 0xFF;

            String hv = Integer.toHexString(v);

            if (hv.length() < 2) {

                stringBuilder.append(0);

            }

            stringBuilder.append(hv);

        }

        return stringBuilder.toString();

    }
}